package com.tbit.uqbike.client.quartz;


import com.tbit.uqbike.client.service.ParkPointService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Author: chen
 * @Description:
 * @Date: 创建于 14:21 2021/4/13
 */
//@Component
@Slf4j
public class ParkPointQuartz {
    @Autowired
    private ParkPointService parkPointService;

    //@Scheduled(cron = "0 0/10 * * * ?")
    public void ParkPointHandler() {
    /*Map<String,List<ParkPoint>> map = SystemData.parkPointMap;
    String updateTime=null;
    if(!map.isEmpty()){
      *//**获取20分钟前的时间*//*
      updateTime=DateTimeUtil.addMinutes(DateTimeUtil.getNowTime(),-20);
    }
    Boolean isEdit=false;
    Integer number = SystemData.parkPointNumber;
    if(number==0){
      Integer total =parkPointService.getNumber();
      SystemData.parkPointNumber=total;
      updateTime=null;
      isEdit=true;
    }else{
      Integer total =parkPointService.getNumber();
      *//**内存记录站点id自增值和实际数据库站点id自增值不一致，需要全量更新*//*
      if(!number.equals(total)){
        SystemData.parkPointNumber=total;
        updateTime=null;
        isEdit=true;
      }
    }
    if(isEdit){
      map=new HashMap<>();
    }
      *//**查询修改过的站点*//*
      List<ParkPoint> parkPoints = parkPointService.getAll(updateTime);
      log.info("更新站点【"+parkPoints.size()+"】");
      if(parkPoints.size()>0){
        GeoHash geoHash = new GeoHash(GeoHashLevel.GHL_M_1200);
        for (ParkPoint parkPoint:parkPoints) {
          *//**进行geohash集合匹配*//*
          String geoString=geoHash.encode(parkPoint.getLa(),parkPoint.getLo());
          List<ParkPoint> parkPointList = map.get(geoString+parkPoint.getAccountId());
          if(parkPointList==null){
            parkPointList= new ArrayList<>();
          }
          if(parkPointList.size()>0){
            Iterator<ParkPoint> iterator = parkPointList.iterator();
            while (iterator.hasNext()){
              ParkPoint p = iterator.next();
              if(p.getParkPointId().equals(parkPoint.getParkPointId())){
                iterator.remove();
                break;
              }
            }
          }
          *//**将数据放入内存*//*
          parkPointList.add(parkPoint);
          map.put(geoString+parkPoint.getAccountId(),parkPointList);
        }
      }
    SystemData.parkPointMap=map;*/
    }

}
